package com.fbty.mt.action.user;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.fbty.base.action.BaseAction;
import com.fbty.mt.service.OtherService;

public class OtherAction extends BaseAction {
	private String country;
	
	private String region;
	
	private List<String> regions;
	
	private List<String> cities;
	
	private List<String> countries;
	
	private List<String> types;
	private OtherService otherService;
	
	public String queryType(){
		types = otherService.queryTypes();
		return "type";
	}
	
	public String queryCountry(){
		 countries = otherService.queryCountry();
		 
		 return "country";
	}
	public String queryRegion(){
		country = "%"+country+"%";
		List<Map<String, String>> list = otherService.queryRegion(country);
		regions = new ArrayList<String>();
		for(Map<String, String> map : list){
			regions.add(map.get("region"));
		}
		return "region";
	}
	
	public String queryCity(){
		country = "%"+country+"%";
		region = "%"+region+"%";
		List<Map<String, String>> list = otherService.queryCity(country, region);
		cities = new ArrayList<String>();
		for(Map<String, String> map : list){
			cities.add(map.get("city"));
		}
		
		return "city";
	}
	
	public String onlyType(){
		types = otherService.onlyTypes();
		return "type";
	}
	
	public String onlyCountry(){
		countries = otherService.onlyCountry();
		
		return "country";
	}
	public String onlyRegion(){
		country = "%"+country+"%";
		List<Map<String, String>> list = otherService.onlyRegion(country);
		regions = new ArrayList<String>();
		for(Map<String, String> map : list){
			regions.add(map.get("region"));
		}
		return "region";
	}
	
	public String onlyCity(){
		country = "%"+country+"%";
		region = "%"+region+"%";
		List<Map<String, String>> list = otherService.onlyCity(country, region);
		cities = new ArrayList<String>();
		for(Map<String, String> map : list){
			cities.add(map.get("city"));
		}
		return "city";
	}





	public void setCountry(String country) {
		this.country = country;
	}



	public void setRegion(String region) {
		this.region = region;
	}


	public void setOtherService(OtherService otherService) {
		this.otherService = otherService;
	}

	public List<String> getRegions() {
		return regions;
	}

	public List<String> getCities() {
		return cities;
	}

	public String getCountry() {
		return country;
	}

	public String getRegion() {
		return region;
	}

	public List<String> getCountries() {
		return countries;
	}

	public List<String> getTypes() {
		return types;
	}

	public OtherService getOtherService() {
		return otherService;
	}
	
	
	
}
